package hr.riteh.assistivecommunicator;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CategoryView extends LinearLayout
{
	private ImageView mImageView;
	private TextView  mTextView;

	public CategoryView(Context context)
	{
		super(context);
		init(context);
	}

	public CategoryView(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		init(context);
	}

	private void init(Context context)
	{
		// Make this vertical linear layout
		setOrientation(LinearLayout.VERTICAL);

		// Create (child) views and add them to layout
		mImageView = new ImageView(context);
		mTextView  = new TextView (context);
		addView(mImageView);
		addView(mTextView);
	}

	public void setCategory(Category category)
	{
		mImageView.setImageBitmap(BitmapFactory.decodeFile(category.getImageName()));
		mTextView.setText(String.format("%s (%d)", category.getName(), category.getUsageCount()));
	}
}
